package com.yaoyong.yy_demo;

import com.yaoyong.yy_demo.config.ScanExcludeFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SuppressWarnings("SpringBootApplicationSetup")
@SpringBootApplication
// 跳过包扫描
//@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.yaoyong.yy_demo.module.spring5.**")})
//@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.yaoyong.yy_demo.module.springboot.**")})
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM, classes = ScanExcludeFilter.class)})
@Slf4j
public class YyDemoApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(YyDemoApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        log.info("\n----------------------------------------------------------\n\t" +
                "Application demo is running! Access URLs:\n\t" +
                "Local: \t\t\thttp://localhost:" + port + "/\n\t" +
                "Druid 监控: \thttp://" + ip + ":" + port + "/druid/index.html\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + "/swagger/index.html\n" +
                "----------------------------------------------------------");
    }

}

